#include<bits/stdc++.h>
#include "graph.h"
#define ls(x) ((x)*2)
#define rs(x) ((x)*2+1)
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define For(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define Rof(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define rep(i,  b) for(int i=1,i##end=b;i<=i##end;i++)
using namespace std;
const int N=1e6+5,base=999983,Mod=998244353;
int tot=2;
int dis[505][505],ans[N];
void solve(){
	int m=NumberOfRoads(),p=Color();
	For(i,1,m){
		Move(i,Color());
		if(Color()!=1){
			dis[p-1][Color()-1]=dis[Color()-1][p-1]=1;
			Move(LastRoad(),Color());
			continue;
		}
		Move(LastRoad(),++tot);
		dis[p-1][tot-1]=dis[tot-1][p-1]=1;
		Move(i,Color());
		int lst=LastRoad();solve();Move(lst,Color());
	}
}
void Inspect(int R){
	memset(dis,0x3f,sizeof dis);
	Move(1,2);Move(LastRoad(),Color());
	solve();tot--;
	For(i,1,tot)dis[i][i]=0;
	For(k,1,tot)For(i,1,tot)For(j,1,tot)
		dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
	For(i,1,tot)For(j,i+1,tot)
		if(dis[i][j]<=R)ans[dis[i][j]]++;
	For(i,1,R) Answer(i,ans[i]);
}
